package com.ruanyun.modular.app.mapper;

import com.ruanyun.modular.app.entity.TUser;
import com.ruanyun.modular.app.model.params.TUserParam;
import com.ruanyun.modular.app.model.result.TUserResult;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author zs
 * @since 2021-04-20
 */
@Repository
public interface TUserMapper extends BaseMapper<TUser> {

    /**
     * 获取列表
     *
     * @author zs
     * @Date 2021-04-20
     */
    List<TUserResult> customList(@Param("paramCondition") TUserParam paramCondition);

    /**
     * 获取map列表
     *
     * @author zs
     * @Date 2021-04-20
     */
    List<Map<String, Object>> customMapList(@Param("paramCondition") TUserParam paramCondition);

    /**
     * 获取分页实体列表
     *
     * @author zs
     * @Date 2021-04-20
     */
    Page<TUserResult> customPageList(@Param("page") Page page, @Param("paramCondition") TUserParam paramCondition);

    /**
     * 获取分页map列表
     *
     * @author zs
     * @Date 2021-04-20
     */
    Page<Map<String, Object>> customPageMapList(@Param("page") Page page, @Param("paramCondition") TUserParam paramCondition);


    @Select("select * from t_user where phone=#{phone}")
    TUserResult getCountByPhone(String phone);


    /**
     * 添加验证标识
     */
    @Insert("insert into t_phone_key(phone,key_val,create_time) values(#{phone},#{keyVal},now())")
    void addPhoneKey(Map<String, Object> map);

    @Select("select * from t_user where phone = #{phone}")
    TUserResult getUserByPhone(String phone);

}
